std::bitset

From Cppreference

Jump to: navigation, search
Defined in header <bitset>

template< size_t N >
class bitset;

Bitsets give the programmer a set of bits as a data structure. Bitsets can be manipulated by various binary operators such as logical AND, OR, and so on.

The size of a C++ bitset is fixed at compile-time, and the size is the template parameter to the bitset.

Contents

Member functions

(constructor)
constructs the bitset
(public member function)
operator=
assigns the contents
(public member function)
operator==
operator!=
compares the contents
(public member function)
Element access
operator[]
accesses specific bit
(public member function)
test
accesses specific bit
(public member function)
all
checks if all bits are set to true
(public member function)
any
checks if any of the bits are set to true
(public member function)
none
checks if no bits are set to true
(public member function)
count
returns the number of bits set to true
(public member function)
Capacity
size
returns the size number of bits that the bitset can hold
(public member function)
Modifiers
operator&=
operator|=
operator^=
operator~
performs binary AND, OR, XOR and NOT
(public member function)
operator<<=
operator>>=
operator<<
operator>>
performs binary shift left and shift right
(public member function)
set
sets bits to true or given value
(public member function)
reset
sets bits to false
(public member function)
flip
toggles the values of bits
(public member function)
Conversions
to_string
returns a string representation of the data
(public member function)
to_ulong
returns a long integer representation of the data
(public member function)
to_ullong (C++0x)
returns a long long integer representation of the data
(public member function)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages